#!/bin/bash
# Script to build and run all examples

set -e  # Exit on error

echo "================================"
echo "Complete Binary Tree Examples"
echo "================================"
echo ""

# Build directory
BUILD_DIR="build"

# Create build directory if it doesn't exist
if [ ! -d "$BUILD_DIR" ]; then
    echo "Creating build directory..."
    mkdir -p "$BUILD_DIR"
fi

# Navigate to build directory
cd "$BUILD_DIR"

# Configure CMake
echo "Configuring CMake..."
cmake .. -DCMAKE_BUILD_TYPE=Release

echo ""
echo "Building project..."
cmake --build . --config Release

echo ""
echo "================================"
echo "Running Examples"
echo "================================"
echo ""

# Run each example
cd examples

echo "┌─────────────────────────────────┐"
echo "│  1. Basic Usage Example         │"
echo "└─────────────────────────────────┘"
./basic_usage
echo ""

echo "┌─────────────────────────────────┐"
echo "│  2. Path Operations Example     │"
echo "└─────────────────────────────────┘"
./path_operations
echo ""

echo "┌─────────────────────────────────┐"
echo "│  3. Iterator Example            │"
echo "└─────────────────────────────────┘"
./iterator_example
echo ""

echo "┌─────────────────────────────────┐"
echo "│  4. Custom Types Example        │"
echo "└─────────────────────────────────┘"
./custom_types
echo ""

echo "================================"
echo "All examples completed successfully!"
echo "================================"
